//use buffer to speedup read write
import java.io.*;


public class Main{
	public static void main(String[] args){
		try{
			byte[] data=new byte[1];
			File srcfile=new File(args[0]);
			File desfile=new File(args[1]);

			BufferedInputStream bufferedinputstream=new BufferedInputStream(new FileInputStream(srcfile));
			BufferedOutputStream bufferedoutputstream=new BufferedOutputStream(new FileOutputStream(desfile));


			System.out.println("copy file:"+srcfile.length()+"byte");

			while(bufferedinputstream.read(data)!=-1){
				bufferedoutputstream.write(data);

			}

			bufferedoutputstream.flush();
			

			bufferedinputstream.close();
			bufferedoutputstream.close();
			System.out.println("copy finish");

		}
		catch(ArrayIndexOutOfBoundsException e){
			System.out.println("exception");
			e.printStackTrace();
		}
		catch(IOException e){
			e.printStackTrace();
		}
	}
}